package com.baizhi.controller;

import com.baizhi.entity.Question;
import com.baizhi.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.util.List;

@RestController
public class QuestionController {
    @Autowired
    private QuestionService qs;

    @GetMapping("/qts")
    public List<Question> selectAll(){
        return qs.selectAll();
    }
    @PostMapping("/qt/insert")
    public void insertQts(@RequestBody Question q, HttpSession session) throws IOException {
        //e.setPicture((String)session.getAttribute("path"));
        qs.insert(q);
    }

    @DeleteMapping("/qt/delete/{id}")
    public void deleteQts(@PathVariable("id") int id){
        //System.out.print(id);
        qs.delete(id);
    }
    @PutMapping("/qt/update")
    public void updateQts(@RequestBody Question q){
        qs.update(q);
    }


}
